﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AgentSite.Master" AutoEventWireup="true" CodeBehind="ShowCustomer.aspx.cs" Inherits="Agents.Agent.ShowCustomer" %>
<%@ Import Namespace="Agents.Data" %>
<asp:Content ID="Header" ContentPlaceHolderID="Header" runat="server">
</asp:Content>
<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server">

    <asp:DetailsView ID="DetailsView" runat="server" DataSourceID="SqlDataSource1" 
            HeaderStyle-Font-Bold="true" CaptionAlign="Right" Width="100%" 
            AllowPaging="False" BorderStyle="None" AutoGenerateRows="false" GridLines="None">
            <Fields>
                <asp:TemplateField ItemStyle-CssClass="header" ShowHeader="false">
                    <ItemTemplate> 
                        פרטי הלקוח <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate> 
                        <br />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="כתובת" ItemStyle-Wrap="false" HeaderStyle-Wrap="false">
                    <ItemTemplate>
                        <asp:Label ID="lblAddress" runat="server" 
                            Text='<%# (new Agents.Queries()).
                            GetClient(Int32.Parse(Eval("Id").ToString())).GetAddress() %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="RegionName" HeaderText="אזור" />
                <asp:BoundField DataField="Phone" HeaderText="טלפון" />
                <asp:BoundField DataField="ContactPerson" HeaderText="איש קשר" />
                <asp:BoundField DataField="EMail" HeaderText="אי מייל" />
                <asp:BoundField DataField="CP" HeaderText="חפ" />
                <asp:BoundField DataField="CreditCardLevel" HeaderText="דרוג כרטיס אשראי" />
                <asp:BoundField DataField="Priority" HeaderText="עדיפות" />
                <asp:BoundField DataField="SaleType" HeaderText="סוג מחירון" />
                <asp:BoundField DataField="AvgOrder" HeaderText="ממוצע להזמנה" />
                <asp:BoundField DataField="LastOrder" HeaderText="הזמנה אחרונה" />
                <asp:BoundField DataField="TotalOrders" HeaderText="מס' הזמנות כולל" />
            </Fields>
        </asp:DetailsView>  
                
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:AgentConnectionString %>" 
            SelectCommand="SELECT Clients.[Id], [City], [Street], [StreetNum], [Phone], 
                              [LastOrder], Clients.[Name], 
                              Regions.Name as RegionName, [ContactPerson],
                              [CreditCardLevel], [CP], [EMail], [Priority], [SaleType], 
                              [AvgOrder], [TotalOrders]
                        FROM [Clients] JOIN [Regions]
                        ON (Clients.Region = Regions.Id)
                        WHERE (Clients.[Id] = @CustomerId)">
                <SelectParameters>
                    <asp:QueryStringParameter QueryStringField="customerId" Name="CustomerId" />
                </SelectParameters>
        </asp:SqlDataSource>
        
        <br />           
        <hr />     

        <div class="alignCenter">    
            <asp:Button ID="btnBack" Text="חזור" runat="server" onclick="btnBack_Click" CssClass="button"/>
        </div>
</asp:Content>
